<?php
/**
 * Admin module. Index controller
 * 
 * @author Konstantin Shamko <konstantin.shamko@gmail.com> 
 * @version 0.0.1
 * @copyright  Copyright (c) 2009 Konstantin Shamko
 * @category VaselinEngine
 * @package Default Module
 * @subpackage Controller
 * @license  New BSD License
 * 
 */
class admin_IndexController extends Bel_Controller{

	/**
	 * Index action
	 *
	 */
	public function indexAction (){

    }
    
    public function deletefileAction(){
        $params = $this->_request->getParams();

        $class_to_call = $params['m'].'_'.ucfirst($params['c']).'Controller';

        $controller = new $class_to_call($this->_request,$this->_response);

        $model=$controller->getModel();

        /*if($class_to_call=='admin_AthletescheduleController' || $class_to_call=='admin_AthleteacademicController'){
            $_u = explode('/',$params['backurl']);
            $athlete_id = $_u[(count($_u)-1)];
            //echo $athlete_id;
            $entry = $model->fetchRow("athlete_id='".$athlete_id."'");
        }else{*/
            $idcol = $model->getIdCol();
            $id = str_replace($idcol.'/','',substr($params['backurl'],strpos($params['backurl'],$idcol)));
            $entry = $model->find($id)->current();
       // }
        
        if($entry){
            $file = $entry->$params['field'];
            $entry->$params['field'] = new Zend_Db_Expr('NULL');
            $entry->save();
            @unlink(HOME_DIR.$file);
        }

        //die;
        $this->_redirect($params['backurl']);
    }    
}